/*
 * @Author: hua
 * @Date: 2020-07-17 17:03:32
 * @description: 
 * @LastEditors: hua
 * @LastEditTime: 2020-07-22 15:56:04
 */
import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

const UserInfoKey = 'Admin-User-Info'

const ProductionBatchKey = "Admin-Production-Batch"

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUserInfo() {
  return window.localStorage.getItem(UserInfoKey) ? JSON.parse(window.localStorage.getItem(UserInfoKey)) : null;
}

export function setUserInfo(userInfo) {
  return window.localStorage.setItem(UserInfoKey, JSON.stringify(userInfo))
}

export function removeUserInfo() {
  window.localStorage.removeItem(UserInfoKey)
  return true
}

export function getProductionBatch() {
  return window.localStorage.getItem(ProductionBatchKey) ? JSON.parse(window.localStorage.getItem(ProductionBatchKey)) : null;
}

export function setProductionBatch(productionBatchInfo) {
  return window.localStorage.setItem(ProductionBatchKey, JSON.stringify(productionBatchInfo))
}

export function removeProductionBatch() {
  window.localStorage.removeItem(ProductionBatchKey)
  return true
}
